import sys; input = sys.stdin.readline; W = []; from bisect import *; X, Y = map(int, input().split()); C = 0; INF = 10**18 while (s:=input().split()): C += 1 if s[0][0] == 'O': ok = 1; xx, yy, ww, hh = map(int, s[1:]) for x, y, dx, dy in W: if (x<=xx X or yy+hh > Y: print(f'Command {C}: OPEN - window does not fit') else: W.append((xx, yy, ww, hh)) elif s[0][0] == 'C': xx, yy = map(int, s[1:]); f = 0 for x, y, dx, dy in W: if x<=xx X or f[2]+hh > Y: print(f'Command {C}: RESIZE - window does not fit') else: W[f[0]] = (f[1], f[2], ww, hh) else: xx, yy, ww, hh = map(int, s[1:]); f = 0 for i, (x, y, dx, dy) in enumerate(W): if x<=xx0, ww<0, hh>0, hh<0].index(1); A = O = (abs(ww), abs(hh), -1)[T//2]; Gi = {*range(len(W))} while True: pr = len(Gi) for _, x2, y2, dx2, dy2 in G: for i in [*Gi]: x, y, dx, dy = W[i] if (y<=y2 ae[bs-1]: d = min(d, v-ae[bs-1]) if d > A or d <= 0: break for i, (j, x, y, dx, dy) in enumerate(G): W[j] = ((x+d, x-d, x, x)[T], (y, y, y+d, y-d)[T], dx, dy); G[i] = (j, *W[j]) while True: pr = len(Gi) for _, x2, y2, dx2, dy2 in G: for i in [*Gi]: x, y, dx, dy = W[i] if (y<=y2